import React from 'react'
// ===================================================================== temp
import './report.css'
import './bundle'
import cd from './temp'
import bz from './bz_temp'
// ===================================================================== global declare
const { $fn, $Lazy, $http, globalConfig } = window
const { COVIDUrl } = globalConfig
// ===================================================================== Lazy
const Page 		= $Lazy.load(()=>import('#tp/page/page-container'))
const PageFull 	= $Lazy.load(()=>import('#tp/page/page-full'))
const AddLast 	= $Lazy.load(()=>import('@cpt/add-last'))
// ===================================================================== component
const temp = { cd, bz }

class Index extends React.Component{
	state = {
		data: []
	}
	
	componentDidMount(){
		const { report_num } = $fn.query()
		$http.submit(this,COVIDUrl+'reports/show', { param:{report_num, is_jsondata: 1} }).then(data=>{
			if($fn.hasArray(data)){
				const infoData = data.map(v => {
					const comp = v.report_comp ? v.report_comp : 'cd'
					const t = +v.check_type === 0 ? temp[comp]['covidTemp'] : temp[comp]['objectTemp']	// check_type:0(人员)，1(物表)
					return { template:t, data: v }
				} )
				setTimeout(()=>window?.jzerRender?.('#preview', infoData))
			}
		})
	}
	
	render(){
		return (
			<AddLast name='预览报告单'>
				<PageFull>
					<Page full>
						<div className='rel ex' id='preview'>
							<div className='abs_full fxmc g9' style={{background:'#eee'}}>无数据</div>
						</div>
					</Page>
				</PageFull>
			</AddLast>
		)
	}
}

export default Index